﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WcfGeebaServer.DBDAL;

namespace WcfGeebaServer.Logging
{
    [Serializable]
    public static class GLogger
    {
        //private static readonly ILog _log = LogManager.GetLogger(typeof(Program));

        static GLogger()
        {
            //log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("app.config"));
        }

        public static void log(string msg)
        {
            try
            {
                if (Data.logDataAdapter.Connection.State != System.Data.ConnectionState.Open)
                {
                    Data.logDataAdapter.Connection.Open();
                }
                Data.logDataAdapter.Insert(DateTime.Now, "INFO: " + msg);
                Data.logData.AddLoggingRow(DateTime.Now, "INFO: " + msg);
            }
            catch
            {
            }
            //Data.logData.AcceptChanges();
            //Data.logData.Add("INFO: " + DateTime.Now + " : " + msg);
            //GLogger._log.Info(msg);
        }
        public static void error(string msg,Exception e)
        {
            try
            {
                if (Data.logDataAdapter.Connection.State != System.Data.ConnectionState.Open)
                {
                    Data.logDataAdapter.Connection.Open();
                }
                Data.logDataAdapter.Insert(DateTime.Now, "ERR: " + msg + ((e == null) ? "" : ":" + e.Message));
                Data.logData.AddLoggingRow(DateTime.Now, "ERR: " + msg + ((e == null) ? "" : ":" + e.Message));
            }
            catch
            {
            }
            //Data.logData.AcceptChanges();
            //Data.logData.Add("ERR: " + DateTime.Now + " : " + msg + ((e == null) ? "" : ":" + e.Message));
            //GLogger._log.Error(msg, e);
        }
    }
}